// 例子12

{
    function add([x, y]) {
		return x + y;
    }
    console.log(add([1, 2])); // 3
}

console.log('----------------------------------')

{
    function move({x = 0, y = 0} = {}) {
        return [x, y];
    }

    console.log(move({x: 3, y: 8})); // [3, 8]
    console.log(move({x: 3})); // [3, 0]
    console.log(move({})); // [0, 0]
    console.log(move()); // [0, 0]
}

console.log('----------------------------------')

{
    function move({x, y} = { x: 0, y: 0 }) {
        return [x, y];
    }

    console.log(move({x: 3, y: 8})); // [3, 8]
    console.log(move({x: 3})); // [3, undefined]
    console.log(move({})); // [undefined, undefined]
    console.log(move()); // [0, 0]
}

console.log('----------------------------------')

{
    let result = [[1, 2], [3, 4]].map(([a, b]) => a + b);
    console.log(result) // [ 3, 7 ]
}